package com.wedimob.tools;

import android.content.Context;
import android.content.SharedPreferences;
import android.preference.PreferenceManager;

public class Preferences {

    static public final String FREEBOX_URL = "freebox_url";
    private String freeboxUrl;

    static public final String FREEBOX_PASS = "freebox_pass";
    private String freeboxPwd;

    static public final String SUSPEND_ACCOUNT = "suspended_checkbox";
    private Boolean isSuspended;

    static public final String WIFI_ON_BEGIN = "wifion_begin";
    private String wifiOnBegin;

    static public final String WIFI_ON_END = "wifion_end";
    private String wifiOnEnd;

    public Boolean isConfigured() {
        return (freeboxUrl != null);
    }

    public String getFreeboxUrl() {
        return freeboxUrl;
    }

    private void setFreeboxUrl(String freeboxUrl) {
        this.freeboxUrl = freeboxUrl;
    }

    public String getFreeboxPwd() {
        return freeboxPwd;
    }

    private void setFreeboxPwd(String freeboxPwd) {
        this.freeboxPwd = freeboxPwd;
    }

    public Boolean isSuspended() {
        return isSuspended;
    }

    private void setIsSuspended(Boolean isSuspended) {
        this.isSuspended = isSuspended;
    }

    public String getWifiOnBegin() {
        return wifiOnBegin;
    }

    private void setWifiOnBegin(String wifiOnBegin) {
        this.wifiOnBegin = wifiOnBegin;
    }

    public String getWifiOnEnd() {
        return wifiOnEnd;
    }

    private void setWifiOnEnd(String wifiOnEnd) {
        this.wifiOnEnd = wifiOnEnd;
    }

    private Context ctx;

    public Preferences(Context ctx) {
        this.ctx = ctx;
    }

    public void load() {
        SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(ctx);
        setFreeboxUrl(prefs.getString(FREEBOX_URL, null));
        setFreeboxPwd(prefs.getString(FREEBOX_PASS, null));
        setIsSuspended(prefs.getBoolean(SUSPEND_ACCOUNT, true));
        setWifiOnBegin(prefs.getString(WIFI_ON_BEGIN, null));
        setWifiOnEnd(prefs.getString(WIFI_ON_END, null));
    }
}
